﻿package idv.cjcat.shintaz.compiler.scanner {
	import flash.utils.Dictionary;
	
	public class TokenDictionary {
		
		private static var _instance:TokenDictionary;
		public static function getInstance():TokenDictionary {
			if (_instance) return _instance;
			_instance = new TokenDictionary();
			return _instance;
		}
		
		private var _keywords:Dictionary;
		public function get keywords():Dictionary { return _keywords; }
		
		private var _delimiters:Dictionary;
		public function get delimiters():Dictionary { return _delimiters; }
		
		//private var _operators:Dictionary;
		//public function get oeprators():Dictionary { return _operators; }
		
		public function TokenDictionary() {
			
			//keywords
			//------------------------------------------------------------------------------------------------
			
			_keywords = new Dictionary();
			
			_keywords["break"]		= Token.BREAK;
			_keywords["case"]		= Token.CASE;
			_keywords["continue"]	= Token.CONTINUE;
			_keywords["default"]	= Token.DEFAULT;
			_keywords["delete"]		= Token.DELETE;
			_keywords["do"]			= Token.DO;
			_keywords["else"]		= Token.ELSE;
			_keywords["for"]		= Token.FOR;
			_keywords["function"]	= Token.FUNCTION;
			_keywords["if"]			= Token.IF;
			_keywords["new"]		= Token.NEW;
			_keywords["return"]		= Token.RETURN;
			_keywords["switch"]		= Token.SWITCH;
			_keywords["this"]		= Token.THIS;
			_keywords["var"]		= Token.VAR;
			_keywords["while"]		= Token.WHILE;
			
			_keywords["true"]		= Token.TRUE;
			_keywords["false"]		= Token.FALSE;
			
			_keywords["null"]		= Token.NULL;
			_keywords["undefined"]	= Token.UNDEFINED;
			
			
			//delimiters
			//------------------------------------------------------------------------------------------------
			
			_delimiters = new Dictionary();
			
			_delimiters["{"]	= Token.BRACE_L;
			_delimiters["}"]	= Token.BRACE_R;
			_delimiters["["]	= Token.BRACK_L;
			_delimiters["]"]	= Token.BRACK_R;
			_delimiters["("]	= Token.PAREN_L;
			_delimiters[")"]	= Token.PAREN_R;
			_delimiters[","]	= Token.COMMA;
			_delimiters["."]	= Token.DOT;
			_delimiters["?"]	= Token.QUESTION;
			_delimiters[";"]	= Token.S_COLON;
			_delimiters[":"]	= Token.COLON;
			
			
			//operators
			//------------------------------------------------------------------------------------------------
			
			/*
			
			_operators = new Dictionary();
			
			_operators["+"]		= Token.PLUS;
			_operators["-"]		= Token.MINUS;
			_operators["*"]		= Token.MUL;
			_operators["/"]		= Token.DIV;
			_operators["<"]		= Token.LT;
			_operators[">"]		= Token.GT;
			_operators["=="]	= Token.EQ;
			_operators["<="]	= Token.LE;
			_operators[">="]	= Token.GE;
			_operators["!="]	= Token.NEQ;
			
			_operators["="]		= Token.ASSIGN;
			_operators["+="]	= Token.ASSIGN_PLUS;
			_operators["-="]	= Token.ASSIGN_MINUS;
			_operators["*="]	= Token.ASSIGN_MUL;
			_operators["/="]	= Token.ASSIGN_DIV;
			
			*/
		}
	}
}